package model.game;

/**
 *
 * @author Dustin
 */
public class Game {
    private int currentPlayerIndex;
    private int dealerIndex;
    private boolean locked;
    private Table table;
    private Player[] players = new Player[Table.TABLE_SIZE];

    public Game(String aName) {
        table = new Table(aName);
    }

    public int getDealerIndex() {
        return dealerIndex;
    }

    public boolean isLocked() {
        return locked;
    }

    public Player getCurrentPlayer() {
        return players[currentPlayerIndex];
    }

    public Player getDealer() {
        return players[dealerIndex];
    }

    public Player getPlayer(int index) {
        return players[index];
    }

    public Player[] getPlayers() {
        return players;
    }

    public Table getTable() {
        return table;
    }

    public void setNextPlayer() {
        currentPlayerIndex = currentPlayerIndex++ % Table.TABLE_SIZE;
    }

    public void setNextDealer() {
        dealerIndex = dealerIndex++ % Table.TABLE_SIZE;
    }

    public void setLocked(boolean value) {
        locked = value;
    }

    public void setPlayer(int index, Player aPlayer) {
        if(!locked) {
            players[index] = aPlayer;
        }
    }
}
